#!/bin/zsh

## 删除旧的临时 allure-report 相关文件
#find "$TMPDIR" -name allure-report 2>/dev/null | while read -r line; do
#  if [ -d "${line}" ]; then
#    echo "${line%/*}"
#    rm -rf "${line%/*}"
#  else
#    echo "no temporary files of allure"
#  fi
#done

# check maven command
if ! mvn -v >/dev/null; then echo "maven not found"; exit 1; fi

# 测试指定 Tag 的测试用例
# mvn -Dgroups=com.zzw.aims.mockcases test
mvn -Dtest=com.zzw.aims.cases.CalculatorTest test

# check allure command
if ! allure --version >/dev/null; then echo "allure not found"; exit 2; fi

# launch allure report serve
allure serve target/allure-results